//--------------------------------------------------------------------------------------
// File: Tutorial04.fx
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------
// Constant Buffer Variables
//--------------------------------------------------------------------------------------
/*cbuffer ConstantBuffer : register( b0 )
{
	matrix World;
	matrix View;
	matrix Projection;
}
*/
RasterizerState CullBack
{
	CullMode = BACK;
	FillMode = SOLID;
};

cbuffer Matrices
{
	float4x4 World : WORLD;
	float4x4 View : VIEW;
	float4x4 Projection : PROJECTION;
}

Texture2D DiffuseTexture : TEXTURE0;

SamplerState WrapLinearSampler
{
	Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Wrap;
    AddressV = Wrap;
};


//--------------------------------------------------------------------------------------
/*struct VS_INPUT
{
	float3 Pos : POSITION;
	float4 Color : COLOR;
};

struct VS_OUTPUT
{
    float4 Pos : SV_POSITION;
    float4 Color : COLOR0;
};*/

struct VS_INPUT
{
	float3 Pos : POSITION;
	float2 TexCoords : TEXCOORD0;
};

struct VS_OUTPUT
{
    float4 Pos : SV_POSITION;
    float2 TexCoords : TEXCOORD0;
};

//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
VS_OUTPUT VS( VS_INPUT input )
{
    VS_OUTPUT output = (VS_OUTPUT)0;
    output.Pos = mul( float4(input.Pos, 1.0), World );
    output.Pos = mul( output.Pos, View );
    output.Pos = mul( output.Pos, Projection );
    //output.Color = input.Color;
	output.TexCoords = input.TexCoords;
    return output;
}


//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( VS_OUTPUT input ) : SV_Target
{
    //return input.Color;
	//return float4(input.TexCoords.x, input.TexCoords.y, 0.0, 1.0);
	return float4(DiffuseTexture.Sample(WrapLinearSampler, input.TexCoords));
}

technique11 generic
{
	pass p0
	{
		SetVertexShader( CompileShader(vs_5_0, VS()) );
		SetGeometryShader(NULL);
		SetPixelShader( CompileShader(ps_5_0, PS()) );
		
		SetRasterizerState(CullBack);
	}
}
